<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
	<composite:attribute name="valor" required="true" />
	<composite:attribute name="label" required="true" />
	<composite:attribute name="editavel" default="true"/>
	<composite:attribute name="titulo" />
	<composite:attribute name="obrigatorio" />
	<composite:attribute name="maxLength" default="8"/>
	<composite:attribute name="size" default="6"/>
	<composite:attribute name="style" />
	<composite:attribute name="desativado" default="false"/>
	<composite:clientBehavior name="onblur" event="blur" targets="#{cc.id}_InputDecimal" />
</composite:interface>

<composite:implementation>
		
		<h:outputText id="#{cc.id}_Label" value="#{cc.attrs.valor}" rendered="#{not cc.attrs.editavel}" style="font-weight:normal;" />
		
		<p:inputText id="#{cc.id}_InputDecimal" onpaste="return false;"
					 label="#{cc.attrs.label}" title="#{cc.attrs.titulo}" 
					 required="#{cc.attrs.obrigatorio}"
					 maxLength="#{cc.attrs.maxLength}"
					 size="#{cc.attrs.size}"
					 value="#{cc.attrs.valor}" onkeyup="campoDecimal_onKeyUp(this, event, 2)" 
					 rendered="#{cc.attrs.editavel}" style="#{cc.attrs.style}" autocomplete="off"
            		 onkeydown="return campoDecimal_onKeyPressLimite(this, event, #{cc.attrs.maxLength})" />
		
		<!-- Necessário devido a um bug do myfaces com ajax utilizando o atributo disabled do componente-->
		<script>
			$(document).ready(function(){
				var disabled = #{cc.attrs.desativado};
					if(disabled == true){
						$("input[id*=#{cc.id}_InputDecimal]").each(function(){
							$(this).attr("disabled", "disabled");
						});
					}
			});
			$(document).ready(function(){
				$("input[id*=#{cc.id}_InputDecimal]").live("copy paste", function(e){
					e.preventDefault();
				});
			});
		</script>
</composite:implementation>
</html>